﻿using Microsoft.Practices.Unity.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Artech.Core.Extensions
{
    public static class StatefulEntryCollectionExtensions
    {
        public static IEnumerable<T> GetEntries<T>(this StatefulEntryCollection<T> entries, EntryState state) where T: StatefulEntry
        {
            Guard.ArgumentNotNull(entries, "entries");
            return entries.Where(entry => entry.State == state);
        }

        public static IEnumerable<T> GetAddedEntries<T>(this StatefulEntryCollection<T> entries) where T: StatefulEntry
        {
            return GetEntries<T>(entries, EntryState.Added);
        }

        public static IEnumerable<T> GetModifiedEntries<T>(this StatefulEntryCollection<T> entries) where T : StatefulEntry
        {
            return GetEntries<T>(entries, EntryState.Modified);
        }

        public static IEnumerable<T> GetDeletedEntries<T>(this StatefulEntryCollection<T> entries) where T : StatefulEntry
        {
            return GetEntries<T>(entries, EntryState.Deleted);
        }
    }
}
